﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _03.CountSubstringInText
{
    class Program
    {
        static void Main(string[] args)
        {
            string text = "We are living in an yellow submarine. We don't have anything else. Inside the submarine is very tight. So we are drinking all the day. We will move out of it in 5 days.";
            Console.WriteLine(text);
            string newText=text.ToLower();
            int count = 0;
            int index = newText.IndexOf("in");
            while (index!=-1)
            {
                count++;
                index = newText.IndexOf("in", index + 1);
            }
            Console.WriteLine("Substring 'in' containes {0} times in the text. ", count);
        }
    }
}
